import React,{ Suspense } from 'react'
import routes from './routerConfig'
import { Redirect, Switch, Route } from 'react-router-dom'

// react-router V5版本写法：
// Suspense 转场组件
// exact 表示精准匹配
// Switch 表示一次只加载一个组件
export default function RouterComp() {
  return (
    <Suspense fallback={<div>加载中...</div>}>
        <Switch>
            <Redirect from="/" to="/home" exact />
            {routes.map((item,index) => <Route key={index} path={item.path} component={item.component}/>)}
        </Switch>
    </Suspense>
  )
}
